//
//  BottomView.m
//  kyMusicPlayer
//
//  Created by 翁科宇 on 2018/5/17.
//  Copyright © 2018年 翁科宇. All rights reserved.
//

#import "BottomView.h"

@implementation BottomView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    //上一曲
    _preSongBtn = [[UIButton alloc] initWithFrame:CGRectMake(frame.size.width / 5, frame.size.height / 2.3, frame.size.width * 0.2, frame.size.width * 0.2)];
    [_preSongBtn setImage:[UIImage imageNamed:@"cm2_fm_btn_pre"] forState:UIControlStateNormal];
    [_preSongBtn setImage:[UIImage imageNamed:@"cm2_fm_btn_pre_prs"] forState:UIControlStateHighlighted];
    [self addSubview:_preSongBtn];
    //播放或暂停
    _playOrPauseBtn = [[UIButton alloc] initWithFrame:CGRectMake(frame.size.width / 2 - frame.size.width * 0.1, frame.size.height / 2.3, frame.size.width * 0.2, frame.size.width * 0.2)];
    [_playOrPauseBtn setImage:[UIImage imageNamed:@"cm2_fm_btn_pause"] forState:UIControlStateNormal];
    [_playOrPauseBtn setImage:[UIImage imageNamed:@"cm2_fm_btn_pause_prs"] forState:UIControlStateHighlighted];
    [self addSubview:_playOrPauseBtn];
    //下一曲
    _nextSongBtn = [[UIButton alloc] initWithFrame:CGRectMake(frame.size.width / 5 * 4 - frame.size.width * 0.2, frame.size.height / 2.3, frame.size.width * 0.2, frame.size.width * 0.2)];
    [_nextSongBtn setImage:[UIImage imageNamed:@"cm2_fm_btn_next"] forState:UIControlStateNormal];
    [_nextSongBtn setImage:[UIImage imageNamed:@"cm2_fm_btn_next_prs"] forState:UIControlStateHighlighted];
    [self addSubview:_nextSongBtn];
    //播放模式
    _playModeBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, frame.size.height / 2.3, frame.size.width * 0.2, frame.size.width * 0.2)];
    [_playModeBtn setImage:[UIImage imageNamed:@"cm2_icn_loop"] forState:UIControlStateNormal];
    [_playModeBtn setImage:[UIImage imageNamed:@"cm2_icn_loop_prs"] forState:UIControlStateHighlighted];
    [self addSubview:_playModeBtn];
    //歌曲列表按键设置
    _songListBtn = [[UIButton alloc] initWithFrame:CGRectMake(frame.size.width * 4 / 5, frame.size.height / 2.3, frame.size.width * 0.2, frame.size.width * 0.2)];
    [_songListBtn setImage:[UIImage imageNamed:@"cm2_icn_list"] forState:UIControlStateNormal];
    [_songListBtn setImage:[UIImage imageNamed:@"cm2_icn_list_prs"] forState:UIControlStateHighlighted];
    [self addSubview:_songListBtn];
    //播放进度条
    _songSlider = [[UISlider alloc] initWithFrame:CGRectMake(frame.size.width / 6, frame.size.height / 4, frame.size.width * 2 / 3, frame.size.height * 0.2)];
    [_songSlider setThumbImage:[UIImage imageNamed:@"cm2_detail_knob_nomal"] forState:UIControlStateNormal];
    [_songSlider setThumbImage:[UIImage imageNamed:@"cm2_detail_knob_prs"] forState:UIControlStateHighlighted];
    _songSlider.tintColor = [UIColor whiteColor];
    [self addSubview:_songSlider];
    //当前播放时间
    _currentTimeLb = [[UILabel alloc] initWithFrame:CGRectMake(5, frame.size.height / 4, frame.size.width / 6 - 10, frame.size.height * 0.2)];
    _currentTimeLb.textColor = [UIColor whiteColor];
    _currentTimeLb.text = @"00:00";
    _currentTimeLb.font = [UIFont systemFontOfSize:15.0];
    _currentTimeLb.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_currentTimeLb];
    // 整歌时间
    _durationTimeLb = [[UILabel alloc] initWithFrame:CGRectMake(frame.size.width * 5 / 6 + 5, frame.size.height / 4, frame.size.width / 6 - 10, frame.size.height * 0.2)];
    _durationTimeLb.textColor = [UIColor whiteColor];
    _durationTimeLb.text = @"00:00";
    _durationTimeLb.font = [UIFont systemFontOfSize:15.0];
    _durationTimeLb.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_durationTimeLb];
    
    return self;
}

@end
